﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using FJERP.Model;
using FJERP.BLL;


namespace FJERP
{
    public partial class Commodityadd : System.Web.UI.Page
    {
        ProductBLL bll = new ProductBLL();
        public void Loadxiala()
        {
            this.Product_Type_Name.DataSource = bll.Product_Type_Show();
            this.Product_Type_Name.DataValueField = "Product_Type_Id";
            this.Product_Type_Name.DataTextField = "Product_Type_Name";
            this.Product_Type_Name.DataBind();
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Loadxiala();
            }
        }
        protected void Unnamed1_Click(object sender, EventArgs e)
        {

            Product sur = new Product();
            sur.Product_Barcode = this.Product_Barcode.Text;
            sur.Product_Bprid = Convert.ToDecimal(this.Product_Bprid.Text);
            sur.Product_frim = this.Product_frim.Text;
            sur.Product_Modelspe = this.Product_Modelspe.Text;
            sur.Product_Name = this.Product_Name.Text;
            sur.Product_Price = Convert.ToDecimal(this.Product_Price.Text);
            sur.Product_Remark = this.Product_Remark.Text;
            sur.Product_Type_Id = Convert.ToInt32(this.Product_Type_Name.SelectedValue);
            sur.Product_Unit_Id = this.Product_Unit_Id.Text;
            if (bll.AddProduct(sur) > 0)
            {
                Response.Write("<script>alert('添加成功');location.href='CommodityShow.aspx';</script>");

            }
            else
            {
                Response.Write("<script>alert('添加失败')</script>");
            }

        }
    }
}